<template>
    <div>
        <erqiaotable :tableData="tableData" @addValue="addValue" @editValue="editValue" />
    </div>
</template>

<script setup>
import erqiaotable from './erqiaotable.vue';
import { ref } from 'vue';
const tableData = ref([
    { id: 1, namech: '飞行器', nameen: 'aircraft', sort: 1, status: true },
    { id: 2, namech: '降落器', nameen: 'lowerator', sort: 3, status: false },
    { id: 3, namech: '漂浮器', nameen: 'levitron', sort: 4, status: true },
    { id: 4, namech: '滑翔器', nameen: 'glider', sort: 7, status: false },
    { id: 5, namech: '机器', nameen: 'machine', sort: 10, status: true },
])

const addValue = (newData) => {
    tableData.value.push(newData)
}

const editValue = (newData) => {
    let index = tableData.value.findIndex(item => item.id === newData.id)
    tableData.value[index] = newData
}
</script>

<style lang="scss" scoped></style>